rm -rf ./channel-artifacts/*
rm -rf ./crypto-config/*

cryptogen generate --config=./crypto-config.yaml

# 生成创始块文件
echo "---------------- Create genesis.block file BEGIN --------------------"
configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ./channel-artifacts/genesis.block -channelID fabric-channel
echo "---------------- Create genesis.block file END --------------------"

# 生成 TwoOrgsChannel 文件
echo "---------------- Create TwoOrgsChannel.tx file BEGIN -------------------"
configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID mychannel
echo "---------------- Create TwoOrgsChannel.tx file END -------------------"

echo "----------------------------------------------------"
configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID mychannel -asOrg Org1MSP
echo "----------------------------------------------------"
configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID mychannel -asOrg Org2MSP
echo "----------------------------------------------------"
configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org3MSPanchors.tx -channelID mychannel -asOrg Org3MSP
# 生成 TwoOrgsChannel 文件
echo "---------------- Create TwoOrgsChannel.tx file BEGIN -------------------"
configtxgen -profile Org2Channel -outputCreateChannelTx ./channel-artifacts/org2channel.tx -channelID org2channel
echo "---------------- Create TwoOrgsChannel.tx file END -------------------"


echo "----------------------------------------------------"
configtxgen -profile Org2Channel -outputAnchorPeersUpdate ./channel-artifacts/Org2Panchors.tx -channelID org2channel -asOrg Org2MSP


